<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="style.css">
    <title>Document</title>
    <style>
        *{
/*禁止选中文本*/
user-select:none ;  
}
body{
    height: 480px;
  
}
#jsq{
    width: 280px;
    height: 400px;
    background: #8b8b8b;
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
    margin: 100px auto;
}
#kong{
    width: 100%;
    height: 60px;
    background:  #8b8b8b;

    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
}
#kuang #shu{
    width: 88%;
    height: 60px;
    margin-left: 12px;
    background:  #8b8b8b;
    border: 1px solid #f4f1f4;
    font-size: 50px;
    color: #ffffff;
    text-align: right;
}
#an{
    width: 100%;
    height: 330px;
    background: #8b8b8b;
    -webkit-border-bottom-right-radius: 10px;
    -webkit-border-bottom-left-radius: 10px;
    -moz-border-radius-bottomright: 10px;
    -moz-border-radius-bottomleft: 10px;
    border-bottom-right-radius: 10px;
    border-bottom-left-radius: 10px;
}
#an .zongan{
    position: relative;
    right: 25px;
   
}
#an li{
    list-style-type:none;
    text-align: center;
    line-height:50px;
    margin: 5px;
    float: left;
    -webkit-border-radius: 50px;
    -moz-border-radius: 50px;
    border-radius: 50px;
    font-size: 25px;
    
}
#an .an1{
    width: 50px;
    height: 50px;
    color: #0c0c0c;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.2), 0 0 0 rgba(255, 255, 255, 0.8),
		inset 4px 4px 8px rgba(0, 0, 0, 0.1),
		inset -4px -4px 8px rgba(255, 255, 255, 1);
    background: linear-gradient(90deg,#03a9f4,#f441a5,#ffeb3b,#03a9f4);
    background-size: 130%;
}

#an .an2{
    width: 50px;
    height: 50px;
    color: #0c0c0c;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.2), 0 0 0 rgba(255, 255, 255, 0.8),
		inset 4px 4px 8px rgba(0, 0, 0, 0.1),
		inset -4px -4px 8px rgba(255, 255, 255, 1);
    background: linear-gradient(90deg,#03a9f4,#f441a5,#ffeb3b,#03a9f4);
    background-size: 190%;
}
#an .an3{
    width: 108px;
    height: 50px;
    color: #0c0c0c;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.2), 0 0 0 rgba(255, 255, 255, 0.8),
		inset 4px 4px 8px rgba(0, 0, 0, 0.1),
		inset -4px -4px 8px rgba(255, 255, 255, 1);
    background: linear-gradient(90deg,#03a9f4,#f441a5,#ffeb3b,#03a9f4);
    background-size: 150%;
   }
h1{
    text-align: center;
}

    </style>
</head>
<body>
    <div id="jsq">
        <div id="kong">
        </div>
        <div id="kuang">
        <input type="text" id="shu" > 
        </div>
        <div id="an">
            <ul class="zongan">
                <li class="an1" onclick="qingping()">C</li>
                <li class="an1" onclick="zhengfuhao()">±</li>
                <li class="an1" onclick="tuige()">Del</li>
                <li class="an2" onclick="chongfufuhao('/')">÷</li>
                <li class="an1" onclick="dianjianniu('7')">7</li>
                <li class="an1" onclick="dianjianniu('8')">8</li>
                <li class="an1" onclick="dianjianniu('9')">9</li>
                <li class="an2" onclick="chongfufuhao('*')">x</li>
                <li class="an1" onclick="dianjianniu('4')">4</li>
                <li class="an1" onclick="dianjianniu('5')">5</li>
                <li class="an1" onclick="dianjianniu('6')">6</li>
                <li class="an2" onclick="chongfufuhao('-')">-</li>
                <li class="an1" onclick="dianjianniu('1')">1</li>
                <li class="an1" onclick="dianjianniu('2')">2</li>
                <li class="an1" onclick="dianjianniu('3')">3</li>
                <li class="an2" onclick="chongfufuhao('+')">+</li>
                <li class="an1" onclick="dianjianniu('0')">0</li>
                <li class="an1" onclick="xiaoshudian('.')">.</li>
                <li class="an3" onclick="dengyu()">=</li>
            </ul>
        </div>
 </div>
<script>
/*全局 变量  出结果后 清空在输入*/
var chujieguohou = false; 
/*实现按钮输出在 input上*/
function dianjianniu(shuzi){
    if(chujieguohou == true){
        document.getElementById('shu').value = "";
        /*在次改 赋值*/
        chujieguohou  =  false;
    }
    var shuchu=document.getElementById('shu').value;
        document.getElementById('shu').value +=shuzi;

}
/*实现计算机的 公式计算功能*/
function dengyu(){
    chujieguohou = true;
    var shuchu=document.getElementById('shu').value;
    var jieguo = eval(shuchu);
    document.getElementById('shu').value =jieguo;
}
/*实现清屏功能*/
function  qingping(){
    var shu=document.getElementById("shu");
    shu.value = "";
    document.getElementById("shu").focus();
}
/*实现退格功能*/    
function tuige(){
var tt=document.getElementById("shu");
tt.value=tt.value.substring(0,tt.value.length-1);
}
/*实现 正负号 功能*/
function zhengfuhao(){
    var zhf=document.getElementById("shu").value;
    if(zhf.charCodeAt(0)==45){
        document.getElementById("shu").value =  zhf.substr(1, zhf.length);
}
    else{
        document.getElementById("shu").value = "-" +zhf;
    }

}
/*防止重复符号 */
/*方案：判断最后一个是否 为符号 是则不输入 不是则输入*/
function chongfufuhao(number){
    var shujie = document.getElementById("shu").value;
    var lastCode = shujie.charCodeAt(shujie.length-1);
    if(!(lastCode == 37 ||lastCode == 47 ||lastCode == 42 ||lastCode == 43 ||lastCode == 45 ||lastCode == 46)){
        document.getElementById("shu").value += number;
    }
}
/*防止小数点重复*/
function xiaoshudian(number){
    var shujie = document.getElementById("shu").value;
    var lastCode = shujie.charCodeAt(shujie.length-1);
    if(!(lastCode == 46)){
        document.getElementById("shu").value += number;
    }
}
</script>
</body>
</html>